package ch.il07.converter.persistence.entities;

public enum AccessLevel {
	USER(0),
	ADMINISTRATOR(1);
	
	private Integer accessLevelId;
	
	private AccessLevel(Integer accessLevelId) {
		this.setAccessLevelId(accessLevelId);
	}
	
	/**
	 * @param accessLevelId the accessLevelId to set
	 */
	public void setAccessLevelId(Integer accessLevelId) {
		this.accessLevelId = accessLevelId;
	}
	
	/**
	 * @return the accessLevelId
	 */
	public Integer getAccessLevelId() {
		return accessLevelId;
	}
	
	/**
	 * Returns the accesslevel with the specified id.
	 * @param id Id of the accessLevel
	 * @return AccessLevel
	 */
	public static AccessLevel getAccessLevelById(Integer id) {
		for(AccessLevel l : AccessLevel.values()) {
			if(id.equals(l.getAccessLevelId())) {
				return l;
			}
		}
		return null;
	}
	
	@Override
	public String toString() {
		return String.format("[Name=%s]", name());
	}
}